package com.ddwl.user.dao;

import com.ddwl.common.constant.BaseEnum;
import com.ddwl.common.dao.TkDao;
import com.ddwl.user.dao.mapper.MenuMapper;
import com.ddwl.user.dao.model.Menu;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * 类MenuDao.java的实现描述：TODO
 *
 * @author zach
 * @Date :2020-06-23 14:37.
 */
@Repository
public class MenuDao extends TkDao<MenuMapper, Menu> {

    @Resource
    private MenuMapper menuMapper;

    /**
     * 查询当前类型code是否存在
     * @param code
     * @param type
     * @return
     */
    public Menu queryMenuByCodeAndType(String code,Integer type){
        Menu menu = new Menu();
        menu.setCode(code);
        menu.setType(type);
        menu.setDflag(BaseEnum.DflagEnum.NOT_DELETE.getCode());
       return baseMapper.selectOne(menu);
    }

    public List<Menu> queryUserMenu(String userId){
        return baseMapper.getUserMenu(userId);
    }

    public List<Menu> getAll() {
        return menuMapper.selectAll();
    }

    public void changeId(Map<String, String> map) {
        menuMapper.changeId(map);
    }

    public void changePid(Map<String, String> map) {
        menuMapper.changePid(map);
    }
}
